<template>
	<view class="storeDetails">
		<view class="store_info_box">
			<view class="ground_store_image">
				<image :src="storeInfo.image" mode=""></image>
			</view>
			<view class="ground_store_info">
				<view class="ground_store_name">
					{{storeInfo.name}}
				</view>
				<view class="ground_store_address">
					{{storeInfo.area}}
					{{storeInfo.address}}
				</view>
			</view>
		</view>
		<view class="ground_list_box">
			<GroundItem v-for="item in productList.lists" :itemData="item" :index="item.id"></GroundItem>
		</view>
		<view class="bottom_op_box">
			<button class="buy_now" @tap="callPhone">联系商家</button>
		</view>
	</view>
</template>

<script>
	import GroundItem from '../../components/groundItem/groundItem.vue'
	import Com from '../../mixin/index.js';
	export default {
		components: {
			GroundItem
		},
		mixins: [Com],
		data() {
			return {
				storeInfo: {},
				page: {
					page: 1,
					page_size: 10
				},
				productList: {
					lists: [],
					total: 1,
					total_page: 0
				},
			};
		},
		onLoad(val) {
			this.storeInfo = JSON.parse(val.info);
			this.getGroProductList();
		},
		methods: {
			getGroProductList() {
				let params = {
					farm_id: this.storeInfo.id,
					...this.page
				};
				this.getList('productList', 'getGroProductList', 'page', params).then(res => {
					uni.stopPullDownRefresh();
				});
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.storeInfo.phone
				})
			},
		}
	}
</script>

<style lang="scss">
	.storeDetails {
		padding: 30rpx 24rpx 120rpx;
		background: #F9F9F9;

		.store_info_box {
			display: flex;
			margin-bottom: 30rpx;
			background-color: #ffffff;
			border-radius: 20rpx;
			padding: 20rpx 22rpx;

			.ground_store_image {
				width: 90rpx;
				height: 90rpx;
				border-radius: 10rpx;
				overflow: hidden;
				flex: none;
				margin-right: 15rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.ground_store_info {
				.ground_store_name {
					font-size: 30rpx;
					color: #222222;
					margin-bottom: 11rpx;
				}

				.ground_store_address {
					font-size: 24rpx;
					color: #999999;
				}
			}
		}

		.bottom_op_box {
			display: flex;
			position: relative;
			width: 100vw;
			align-items: center;
			background: #ffffff;
			justify-content: space-between;
			padding: 19rpx 23rpx;
			position: fixed;
			box-sizing: border-box;
			bottom: 0;
			left: 0;

			.buy_now {
				width: 96%;
				height: 80rpx;
				background: #fed100;
				border-radius: 40rpx;
				font-size: 30rpx;
			}
		}
	}
</style>